<?php

namespace App\Http\Controllers;


class ApiController extends Controller
{
    public function __construct()
    {
//        $user = \Auth::user();
//        if (!empty($user)) {
//            if (empty($user->status)) {
//                return $this->failed("用户已禁用");
//            }
//            return true;
//        }

    }

    protected function respond($status, $respond)
    {
        return response()->json(['flag' => $status, is_string($respond) ? 'msg' : 'data' => $respond]);
    }

    protected function success($respond = 'success!')
    {
        return $this->respond(true, $respond);
    }

    protected function failed($respond = 'failed!')
    {
        return  $this->respond(false, $respond);
    }

}
